﻿<?xml version="1.0" encoding="utf-8" ?>
<c2eventsheet>
    <!--All the 'name' attributes are ignored by Construct 2 - they are there for readability only.-->
    <name>Main Events</name>
    <events>
        <variable constant="0" name="GameScore" static="0" type="number">0</variable>
        <variable constant="1" name="MAX_ENEMIES" static="0" type="number">10</variable>
        <event-block>
            <conditions>
                <condition id="-1" name="Every tick" type="System" />
            </conditions>
            <actions>
                <action id="-22" name="Set angle toward position" type="Shooter">
                    <param id="0" name="X">Mouse.X</param>
                    <param id="1" name="Y">Mouse.Y</param>
                </action>
            </actions>
            <sub-events>
                <event-block>
                    <conditions>
                        <condition id="-8" name="Compare two values" type="System">
                            <param id="0" name="First value">Enemy.Count</param>
                            <param id="1" name="Comparison">2</param>
                            <param id="2" name="Second value">MAX_ENEMIES</param>
                        </condition>
                    </conditions>
                    <actions>
                        <action id="-3" name="Create object" type="System">
                            <param id="0" name="Object to create">Enemy</param>
                            <param id="1" name="Layer">&quot;Main&quot;</param>
                            <param id="2" name="X">choose(random(0, Shooter.X - 200),random(Shooter.X + 200, LayoutWidth))</param>
                            <param id="3" name="Y">choose(random(0, Shooter.Y - 200),random(Shooter.Y + 200, LayoutHeight))</param>
                        </action>
                        <action behavior="Bullet" id="3" name="Set angle of motion" type="Enemy">
                            <param id="0" name="Angle">random(360)</param>
                        </action>
                        <action behavior="Bullet" id="0" name="Set speed" type="Enemy">
                            <param id="0" name="Speed">random(50,300) + GameScore * 2</param>
                        </action>
                    </actions>
                </event-block>
            </sub-events>
        </event-block>
        <event-block>
            <conditions>
                <condition id="0" name="On collision with another object" type="Bullet">
                    <param id="0" name="Object">Enemy</param>
                </condition>
            </conditions>
            <actions>
                <action id="-12" name="Subtract from" type="Enemy">
                    <param id="0" name="Instance variable">Health</param>
                    <param id="1" name="Value">100</param>
                </action>
                <action id="-9" name="Destroy" type="Bullet" />
            </actions>
            <sub-events>
                <event-block>
                    <conditions>
                        <condition id="-7" name="Compare instance variable" type="Enemy">
                            <param id="0" name="Instance variable">Health</param>
                            <param id="1" name="Comparison">3</param>
                            <param id="2" name="Value">0</param>
                        </condition>
                    </conditions>
                    <actions>
                        <action id="-9" name="Destroy" type="Enemy" />
                        <action id="-10" name="Add to" type="System">
                            <param id="0" name="Variable">GameScore</param>
                            <param id="1" name="Value">1</param>
                        </action>
                        <action id="0" name="Set text" type="ScoreText">
                            <param id="0" name="Text">&quot;Score: &quot; &amp; GameScore</param>
                        </action>
                    </actions>
                </event-block>
            </sub-events>
        </event-block>
        <event-block>
            <conditions>
                <condition id="0" name="On collision with another object" type="Enemy">
                    <param id="0" name="Object">Shooter</param>
                </condition>
                <condition id="-8" inverted="1" name="Is boolean instance variable set" type="Shooter">
                    <param id="0" name="Instance variable">Invincible</param>
                </condition>
            </conditions>
            <actions>
                <action behavior="Flash" id="0" name="Flash" type="Shooter">
                    <param id="0" name="&apos;On&apos; time">0.1</param>
                    <param id="1" name="&apos;Off&apos; time">0.1</param>
                    <param id="2" name="Duration">2</param>
                </action>
                <action id="-12" name="Subtract from" type="Shooter">
                    <param id="0" name="Instance variable">Health</param>
                    <param id="1" name="Value">1</param>
                </action>
                <action id="0" name="Set text" type="HealthText">
                    <param id="0" name="Text">&quot;Health: &quot; &amp; Shooter.Health</param>
                </action>
                <action id="-13" name="Set boolean" type="Shooter">
                    <param id="0" name="Instance variable">Invincible</param>
                    <param id="1" name="Value">1</param>
                </action>
            </actions>
        </event-block>
        <event-block>
            <conditions>
                <condition behavior="Flash" id="1" name="On flash ended" type="Shooter" />
            </conditions>
            <actions>
                <action id="-13" name="Set boolean" type="Shooter">
                    <param id="0" name="Instance variable">Invincible</param>
                    <param id="1" name="Value">0</param>
                </action>
            </actions>
        </event-block>
        <event-block any="1">
            <conditions>
                <condition id="0" name="On click" type="Mouse">
                    <param id="0" name="Mouse button">0</param>
                    <param id="1" name="Click type">0</param>
                </condition>
            </conditions>
            <actions>
                <action id="0" name="Spawn another object" type="Shooter">
                    <param id="0" name="Object">Bullet</param>
                    <param id="1" name="Layer">&quot;Main&quot;</param>
                    <param id="2" name="Image point">&quot;Gun&quot;</param>
                </action>
            </actions>
        </event-block>
        <event-block>
            <conditions>
                <condition id="-6" name="Every X seconds" type="System">
                    <param id="0" name="Interval (seconds)">random(10,30)</param>
                </condition>
                <condition id="-8" name="Compare two values" type="System">
                    <param id="0" name="First value">Health.Count</param>
                    <param id="1" name="Comparison">3</param>
                    <param id="2" name="Second value">0</param>
                </condition>
            </conditions>
            <actions>
                <action id="-3" name="Create object" type="System">
                    <param id="0" name="Object to create">Health</param>
                    <param id="1" name="Layer">&quot;Main&quot;</param>
                    <param id="2" name="X">random(LayoutWidth)</param>
                    <param id="3" name="Y">random(LayoutHeight)</param>
                </action>
            </actions>
        </event-block>
        <event-block>
            <conditions>
                <condition id="0" name="On collision with another object" type="Shooter">
                    <param id="0" name="Object">Health</param>
                </condition>
            </conditions>
            <actions>
                <action id="-9" name="Destroy" type="Health" />
                <action id="-10" name="Set value" type="Shooter">
                    <param id="0" name="Instance variable">Health</param>
                    <param id="1" name="Value">clamp(Self.Health + 1,0,100)</param>
                </action>
                <action id="0" name="Set text" type="HealthText">
                    <param id="0" name="Text">&quot;Health: &quot; &amp; Shooter.Health</param>
                </action>
            </actions>
        </event-block>
    </events>
</c2eventsheet>
